import rospy

from geometry_msgs.msg import Twist

def __keyboard_callback(msg):
    v = msg.linear.x
    w = msg.angular.z

    if v != 0 or w !=0:
        rospy.loginfo('v={} | w={}. | msg={}'.format(v, w, msg))


rospy.init_node('key_test', anonymous=False)

__keyboard_topic = '/key_vel'
rospy.Subscriber(__keyboard_topic, Twist, callback=__keyboard_callback, queue_size=1, buff_size=1)

rospy.spin()